package utils{
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	
	public class FileUtils{
		public static function getFileContents(fileName:String):String{
			var file:File = getDataDirectory().resolvePath(fileName);
			var fileReader:FileStream = new FileStream();
			fileReader.open(file,FileMode.READ);
			var str:String = fileReader.readUTFBytes(fileReader.bytesAvailable);
			fileReader.close();			
			return str;
		}
		
		public static function log(str:String):void{
			var file:File = getDataDirectory().resolvePath("errorlog.txt");
			var fileStream:FileStream = new FileStream();
			fileStream.open(file,FileMode.APPEND);
			fileStream.writeUTFBytes(str);
			fileStream.close();			
		}
		
		public static function getDataDirectory():File{
//			trace(File.applicationStorageDirectory.nativePath);
//			return File.applicationDirectory.resolvePath("kirtanSync");
			return File.documentsDirectory.resolvePath("kirtanSync");
		}		
	}
}